with v8.Class_Data;
with v8.Generic_Handles;
limited with v8.Class_Number, v8.Class_Integer, v8.Class_Int32, v8.Class_Uint32;
limited with v8.Class_Boolean, v8.Class_String;
limited with v8.Class_Object;
package v8.Class_Value is
   type Value(<>) is new v8.Class_Data.Data with private;
   type Pointer is access all Value;
   -- The superclass of all JavaScript values and objects.

   type Value_Array is array (Positive range <>) of Pointer;

   pragma No_Strict_Aliasing(Pointer);
   package Handles is new v8.Generic_Handles(Pointer);


   function Is_Undefined (this : Value) return bool;
   -- Returns true if this value is the undefined value.  See ECMA-262 4.3.10.

   function Is_Null (this : Value) return bool;
   -- Returns true if this value is the null value.  See ECMA-262 4.3.11.

   function Is_True (this : Value) return bool;
   -- Returns true if this value is true

   function Is_False (this : Value) return bool;
   -- Returns true if this value is false.

   function Is_String (this : Value) return bool;
   -- Returns true if this value is an instance of the String type. See ECMA-262 8.4.

   function Is_Function (this : Value) return bool;
   -- Returns true if this value is a function.

   function Is_Array (this : Value) return bool;
   -- Returns true if this value is an array.

   function Is_Object (this : Value) return bool;
   -- Returns true if this value is an object.

   function Is_Boolean (this : Value) return bool;
   -- Returns true if this value is boolean.

   function Is_Number (this : Value) return bool;
   -- Returns true if this value is a number.

   function Is_External (this : Value) return bool;
   -- Returns true if this value is external.

   function Is_Int32 (this : Value) return bool;
   -- Returns true if this value is a 32-bit signed integer.

   function Is_Uint32 (this : Value) return Bool;
   -- Returns true if this value is a 32-bit unsigned integer.

   function Is_Date (this : Value) return bool;
   -- Returns true if this value is a Date.

   function Is_Boolean_Object (this : Value) return bool;
   -- Returns true if this value is a Boolean object.

   function Is_Number_Object (this : Value) return bool;
   -- Returns true if this value is a Number object.

   function Is_String_Object (this : Value) return bool;
   -- .Returns true if this value is a String object.

   function Is_Native_Error (this : Value) return bool;
   -- Returns true if this value is a NativeError.

   function Is_Reg_Exp (this : Value) return bool;
   -- .Returns true if this value is a RegExp.

   function To_Boolean (this : Value) return v8.Class_Boolean.Pointer;
   -- return Local<Boolean>

   function To_Number (this : Value) return v8.Class_Number.Pointer;
   -- return Local<Number>

   function To_String (this : Value) return v8.Class_String.Pointer;
   -- return Local<String>

   function To_Detail_String (this : Value) return v8.Class_String.Pointer;
   -- return Local<String>

   function To_Object (this : Value) return v8.Class_Object.Pointer;
   -- return Local<Object>

   function To_Integer (this : Value) return v8.Class_Integer.Pointer;
   -- return Local<Integer>

   function To_Uint32 (this : Value) return v8.Class_Uint32.Pointer;
   -- return Local<Uint32>

   function To_Int32 (this : Value) return v8.Class_Int32.Pointer;
   -- return Local<Int32>

   function To_Array_Index (this : Value) return v8.Class_Uint32.Pointer;
   -- return Local<Uint32>
   -- Attempts to convert a string to an array index.
   -- Returns an empty handle if the conversion fails.



   function Boolean_Value (this : Value) return bool;

   function Number_Value (this : Value) return double;

   function Integer_Value (this : Value) return int64_t;

   function Uint32_Value (this : Value) return uint32_t;

   function Int32_Value (this : Value) return int32_t;

   function Equals (this : Value; that_value : Pointer) return bool;
   function Strict_Equals (this : Value; that : Pointer) return bool;
   -- .js ==


   function As_Value (this : access Value) return Pointer;
   -- Contravariance
private
   type Value is new v8.Class_Data.Data with null record;

   -- pragma Import (CPP, Value);
   pragma Import (CPP, Is_Undefined, "_ZNK2v85Value11IsUndefinedEv");
   pragma Import (CPP, Is_Null, "_ZNK2v85Value6IsNullEv");
   pragma Import (CPP, Is_True, "_ZNK2v85Value6IsTrueEv");
   pragma Import (CPP, Is_False, "_ZNK2v85Value7IsFalseEv");
   pragma Import (CPP, Is_String, "_Z8IsStringPN2v85ValueE");
   pragma Import (CPP, Is_Function, "_ZNK2v85Value10IsFunctionEv");
   pragma Import (CPP, Is_Array, "_ZNK2v85Value7IsArrayEv");
   pragma Import (CPP, Is_Object, "_ZNK2v85Value8IsObjectEv");
   pragma Import (CPP, Is_Boolean, "_ZNK2v85Value9IsBooleanEv");
   pragma Import (CPP, Is_Number, "_ZNK2v85Value8IsNumberEv");
   pragma Import (CPP, Is_External, "_ZNK2v85Value10IsExternalEv");
   pragma Import (CPP, Is_Int32, "_ZNK2v85Value7IsInt32Ev");
   pragma Import (CPP, Is_Uint32, "_ZNK2v85Value8IsUint32Ev");
   pragma Import (CPP, Is_Date, "_ZNK2v85Value6IsDateEv");
   pragma Import (CPP, Is_Boolean_Object, "_ZNK2v85Value15IsBooleanObjectEv");
   pragma Import (CPP, Is_Number_Object, "_ZNK2v85Value14IsNumberObjectEv");
   pragma Import (CPP, Is_String_Object, "_ZNK2v85Value14IsStringObjectEv");
   pragma Import (CPP, Is_Native_Error, "_ZNK2v85Value13IsNativeErrorEv");
   pragma Import (CPP, Is_Reg_Exp, "_ZNK2v85Value8IsRegExpEv");
   pragma Import (CPP, To_Boolean, "_ZNK2v85Value9ToBooleanEv");
   pragma Import (CPP, To_Number, "_ZNK2v85Value8ToNumberEv");
   pragma Import (CPP, To_String, "_ZNK2v85Value8ToStringEv");
   pragma Import (CPP, To_Detail_String, "_ZNK2v85Value14ToDetailStringEv");
   pragma Import (CPP, To_Object, "_ZNK2v85Value8ToObjectEv");
   pragma Import (CPP, To_Integer, "_ZNK2v85Value9ToIntegerEv");
   pragma Import (CPP, To_Uint32, "_ZNK2v85Value8ToUint32Ev");
   pragma Import (CPP, To_Int32, "_ZNK2v85Value7ToInt32Ev");
   pragma Import (CPP, To_Array_Index, "_ZNK2v85Value12ToArrayIndexEv");
   pragma Import (CPP, Boolean_Value, "_ZNK2v85Value12BooleanValueEv");
   pragma Import (CPP, Number_Value, "_ZNK2v85Value11NumberValueEv");
   pragma Import (CPP, Integer_Value, "_ZNK2v85Value12IntegerValueEv");
   pragma Import (CPP, Uint32_Value, "_ZNK2v85Value11Uint32ValueEv");
   pragma Import (CPP, Int32_Value, "_ZNK2v85Value10Int32ValueEv");
   pragma Import (CPP, Equals, "_ZNK2v85Value6EqualsENS_6HandleIS0_EE");
   pragma Import (CPP, Strict_Equals, "_ZNK2v85Value12StrictEqualsENS_6HandleIS0_EE");

   function As_Value (this : access Value) return Pointer is (Pointer(this));

end v8.Class_Value;
